package com.itmuch.controll;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import com.itmuch.pojo.User;

/** 
* @author  	  Lanxg 
* @E-mail  	  757553326@qq.com 
* @version    1.0 
* @createDate 2018年6月28日 上午10:35:13 
* class desc  
*/
@RestController
public class MovieController {
    @Autowired
	private RestTemplate restTemplate;
    @Autowired
    private LoadBalancerClient  loadBalancerClient;
    
    @GetMapping("/{id}")
    public User findById(@PathVariable Long id)
    {
    	User findOne = this.restTemplate.getForObject("http://microservice-provider-user/"+id,User.class);
    	return findOne;
    }
    @GetMapping("/log-instance")
    public void instance()
    {
    	ServiceInstance serviceinstance = this.loadBalancerClient.choose("microservice-provider-user");
    	//输出负载信息serviceinstance.getServiceId()
    	
    }
}
